package org.jeecg.modules.zhima.center.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.zhima.center.entity.PmsProduct;
import org.jeecg.modules.zhima.center.mapper.PmsProductMapper;
import org.jeecg.modules.zhima.center.service.IPmsProductService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: pms_product
 * @Author: jeecg-boot
 * @Date:   2020-08-27
 * @Version: V1.0
 */

@Service
public class PmsProductServiceImpl extends ServiceImpl<PmsProductMapper, PmsProduct> implements IPmsProductService {

    @Override
    public List<PmsProduct> getByIds(List<Integer> ids) {
        return list(new LambdaQueryWrapper<PmsProduct>().eq(PmsProduct::getDeleteStatus, 0)
                .eq(PmsProduct::getNewStatus, 1) //新品
                .eq(PmsProduct::getPublishStatus, 1) //上架
                .eq(PmsProduct::getDeleteStatus, 0)
                .in(PmsProduct::getId, ids)
//                .eq(PmsProduct::getRecommandStatus, 1) //推荐
//                .eq(PmsProduct::getVerifyStatus, 1) //审核通过
        );
    }

    @Override
    public List<PmsProduct> listByCategoryId(Integer categoryId) {
        return list(new LambdaQueryWrapper<PmsProduct>()
                .eq(PmsProduct::getProductCategoryId, categoryId)
                .eq(PmsProduct::getDeleteStatus, 0)
                .eq(PmsProduct::getPublishStatus, 1));
    }

    @Override
    public IPage<PmsProduct> pageList(Page<PmsProduct> page, QueryWrapper<PmsProduct> queryWrapper) {
        LambdaQueryWrapper<PmsProduct> wrapper = queryWrapper.lambda();
        wrapper.eq(PmsProduct::getDeleteStatus, 0)
                .eq(PmsProduct::getPublishStatus, 1)
                .orderByDesc(PmsProduct::getSort);
        return page(page, wrapper);
    }

}
